package cn.hdu.liang.ch4;

import java.util.List;
import java.util.stream.Collectors;

import static cn.hdu.liang.ch4.Dish.menu;

public class HighCaDish {
    public static void main(String[] args) {
        List<String> threeHighCaDishName = menu.stream()
                .filter(d -> {
                    System.out.println("filtering "+d.getName());
                    return d.getCalories() > 300;
                })
                .map(d->{
                    System.out.println("mapping "+d.getName());
                    return d.getName();
                })
                .limit(3)
                .collect(Collectors.toList());
        System.out.println(threeHighCaDishName);

        long result = menu.stream()
                .filter(d -> {
                    System.out.println("filtering " + d.getName());
                    return d.getCalories() > 300;
                })
                .map(d -> {
                    System.out.println("mapping " + d.getName());
                    return d.getName();
                })
                .limit(3)
                .count();
        System.out.println(result);
    }
}
